
/**
 * 2011-12-31 滚动图 可自动补足数量 2012-1-4
 */
	$.ffui.slider =function(options) {
		var o = {
			type : 0,
			btnLeft : "",
			btnRight : "",
			scBox : "",
			step : 200,
			timer : 500,
			count : 4,
			showCount : 4,
			isTurn : true,
			top : 0,
			left : 0,
			startCount : 0,
			autoPlay : true
		};
		$.extend(o, options);
		var isOver = true;
		$("#" + o.btnLeft).click(function() {
					if (isOver) {
						stopPlay();
						move(false);
					}
				});
		$("#" + o.btnRight).click(function() {
					if (isOver) {
						stopPlay();
						move(true);
					}
				});
		var $scBox = $("#" + o.scBox);
		var nowCount = o.startCount;
		var left = o.left;
		var top = o.top;
		var posStr = "";
		$scBox.css({
					left : left,
					top : top
				});
		// 自动补足个数
		$scBox.append($scBox.children().clone());

		var move = function(flag) {
			isOver = false;
			if (o.type == 1) {
				posStr = "top";
				if (!flag) {
					if (o.isTurn) {
						if (nowCount == 0) {
							nowCount = o.count;
							$scBox.css(posStr, -(nowCount * o.step) + "px");
						}
						top = -(nowCount - 1) * o.step;
					} else {
						if (nowCount != 0) {
							top = -(nowCount - 1) * o.step;
						}
					}
				} else {
					if (o.isTurn
							|| (!o.isTurn && (nowCount != o.count - o.showCount))) {
						top = -(nowCount + 1) * o.step;
					}
				}
			} else {
				posStr = "left";
				if (!flag) {
					if (o.isTurn) {
						if (nowCount == 0) {
							nowCount = o.count;
							$scBox.css(posStr, -(nowCount * o.step) + "px");
						}
						left = -(nowCount - 1) * o.step;
					} else {
						if (nowCount != 0) {
							left = -(nowCount - 1) * o.step;
						}
					}
				} else {
					if (o.isTurn
							|| (!o.isTurn && (nowCount != o.count - o.showCount))) {
						left = -(nowCount + 1) * o.step;
					}
				}
			}
			$scBox.animate({
						left : left + "px",
						top : top + "px"
					}, {
						duration : o.timer,
						complete : function() {
							if (flag) {
								nowCount += 1;
								if (o.isTurn) {
									if (nowCount > (o.count - 1)) {
										nowCount = 0;
										$scBox.css(posStr, "0px");
									}
								} else {
									if ((nowCount + o.showCount) > o.count) {
										nowCount -= 1;
									}
								}
							} else {
								if (o.isTurn || (!o.isTurn && nowCount != 0)) {
									nowCount -= 1;
								}
							}
							isOver = true;

							autoPlay();

						}
					});
		};

		// auto
		var autoTimer = "";
		var autoPlay = function() {
			if (o.autoPlay) {
				autoTimer = setTimeout(function() {
							move(true);
						}, 3000);
			}
		};
		var stopPlay = function() {
			if (o.autoPlay) {
				clearTimeout(autoTimer);
			}
		};

		autoPlay();

	};